let mut src = try!(PathSource::for_path(&manifest_path.dir_path()));
try!(src.update());
let root = try!(src.get_root_package());
+ let env = options.env;
let mut bins = root.get_manifest().get_targets().iter().filter(|a| {
- a.is_bin() && a.get_profile().is_compile()
+ a.is_bin() && a.get_profile().get_env() == env
});
let bin = try!(bins.next().require(|| {
human("a bin target must be available for `cargo run`")
}
let compile = try!(ops::compile(manifest_path, options));
- let mut exe = manifest_path.dir_path().join("target");
- if options.env == "release" {
- exe = exe.join("release");
- }
- let exe = exe.join(bin.get_name());
+ let dst = manifest_path.dir_path().join("target");
+ let dst = match options.target {
+ Some(target) => dst.join(target),
+ None => dst,
+ };
+ let exe = match bin.get_profile().get_dest() {
+ Some(s) => dst.join(s).join(bin.get_name()),
+ None => dst.join(bin.get_name()),
+ };
let exe = match exe.path_relative_from(&os::getcwd()) {
Some(path) => path,
None => exe,
output);
})
+#[cfg(not(windows))] // FIXME(#456)
test!(bench_dylib {
let p = project("foo")
.file("Cargo.toml", r#"
test!(simple_cargo_run {
if disabled() { return }
- let target = alternate();
-
- let build = project("builder")
- .file("Cargo.toml", r#"
- [project]
- name = "foo"
- version = "0.5.0"
- authors = ["wycats@example.com"]
- "#)
- .file("src/main.rs", format!(r#"
- fn main() {{
- assert_eq!(std::os::getenv("TARGET").unwrap().as_slice(), "{}");
- }}
- "#, target).as_slice());
- assert_that(build.cargo_process("cargo-run").arg("--target").arg(target),
- execs().with_status(0));
-
let p = project("foo")
- .file("Cargo.toml", format!(r#"
+ .file("Cargo.toml", r#"
[package]
name = "foo"
version = "0.0.0"
authors = []
- build = '{}'
- "#, build.bin("foo").display()))
+ "#)
.file("src/main.rs", r#"
use std::os;
fn main() {
"#);
let target = alternate();
- assert_that(p.cargo_process("cargo-run").arg("--target").arg(target),
+ assert_that(p.cargo_process("run").arg("--target").arg(target),
execs().with_status(0));
})
fn main() { if !cfg!(ndebug) { fail!() } }
"#);
- assert_that(p.cargo_process("cargo-run").arg("--release"),
+ assert_that(p.cargo_process("run").arg("--release"),
execs().with_status(0).with_stdout(format!("\
{compiling} foo v0.0.1 ({dir})
{running} `target{sep}release{sep}foo`